package com.example.flushdemo.enums;

import com.example.flushdemo.domain.SoftVo;
import lombok.AllArgsConstructor;
import lombok.Data;

import java.util.*;

/**
 * @ClassName Soft
 * @Description
 * @Author Administrator
 * @Date 2022/6/26 0026 14:40
 * @Version 1.0
 */
@Data
@AllArgsConstructor
public class Soft {

    List<Integer> all;

    Map<String,String> hashMap;

    Random random;


    /**
     * 为避免刷数据过程中频繁访问数据库,这里采用常量类
     * 多1 4 8 9 12---------中等3 6 10 11 13 14 15---------少2 5 7 目前设置大概比例为3：2：1
     * 谷歌、内网邮箱、PDF RAR WPS刷多一点 国网安全屏保、5100打印机驱动、HP P3015打印机驱动三个刷少一点；其它的中等
     */
    public Soft(){
        this.random = new Random();
        this.all = Arrays.asList(
                1,4,8,9,12,
                3,6,10,11,13,14,15,
                1,4,8,9,12,
                1,4,8,9,12,
                3,6,10,11,13,14,15,
                2,5,7
        );
        this.hashMap = new HashMap<>();
        hashMap.put("1","谷歌浏览器.exe");
        hashMap.put("2","国网安全屏保.rar");
        hashMap.put("3","国网安全浏览器.exe");
        hashMap.put("4","内网邮箱客户端.exe");
        hashMap.put("5","5100打印机驱动.rar");
        hashMap.put("6","flash插件.exe");
        hashMap.put("7","HP P3015打印机驱动.rar");
        hashMap.put("8","PDF阅读器.exe");
        hashMap.put("9","WinRAR压缩.exe");
        hashMap.put("10","360极速浏览器.exe");
        hashMap.put("11","极点五笔.exe");
        hashMap.put("12","WPS.exe");
        hashMap.put("13","方正小标宋.ttf");
        hashMap.put("14","即时通讯.exe");
        hashMap.put("15","楷体_GB2312.ttf");
    }

    /**
     * 比例3:2:1
     * @return 软件实体
     */
    public SoftVo getSoft(){
        int i = random.nextInt(all.size());
        Integer index = all.get(i);
        return new SoftVo(index+"",hashMap.get(index+""));
    }
}
